package top.wshape1.rpc.loadbalance;

import top.wshape1.rpc.common.extension.ExtensionLoader;
import top.wshape1.rpc.config.JJRpcConfig;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2024-02-10
 */

public class LoadBalanceFactory {

    private static final ExtensionLoader<LoadBalance> loader = ExtensionLoader.getExtensionLoader(LoadBalance.class);

    private static LoadBalance loadBalance;

    public static LoadBalance getLoadBalance() {
        if (loadBalance == null) {
            loadBalance = loader.getExtension(JJRpcConfig.CONFIG.getConsumer().getLoadBalance());
        }
        return loadBalance;
    }

    public static void setLoadBalance(LoadBalance loadBalance) {
        LoadBalanceFactory.loadBalance = loadBalance;
    }

}
